package com.cloudsigns.factorymanager2.project.presenter;

import com.cloudsigns.factorymanager2.project.iview.IAddEngineeringInstallationOrderView1;
import com.cloudsigns.factorymanager2.project.model.AddEngineeringInstallationOrderModel1;
import com.cloudsigns.factorymanager2.project.model.IAddEngineeringInstallationOrderModel1;

public class AddEngineeringInstallationOrderPresenter1 {
    private IAddEngineeringInstallationOrderView1 view;
    private IAddEngineeringInstallationOrderModel1 model;
    private android.os.Handler mHandler = new android.os.Handler();

    public AddEngineeringInstallationOrderPresenter1(IAddEngineeringInstallationOrderView1 view) {
        this.view = view;
        this.model = new AddEngineeringInstallationOrderModel1();
    }

    public void addEngineeringInatallationOrder1() {

        model.addEngineeringInatallationOrder1(view.getCompleteDate(),
                view.getEngineeringAddress(), view.getEngineeringName(),
                view.getLat(),view.getLon(),view.getPicUrl(),
                view.getProjectName(), view.getProductBeans(),
                new AddEngineeringInstallationOrderModel1.OnAddEngineeringInstallationOrderListener1() {

            @Override
            public void success(final String projectId) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.addEngineeringInstallatonOrderSuccess(projectId);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showFailedError(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
